package org.oslims.client.view.impl;

import org.oslims.client.uicomponents.ConfirmationBox;
import org.oslims.client.uicomponents.editbox.EditMixtureBox;
import org.oslims.client.uicomponents.editbox.EnterStoragePlaceBox;
import org.oslims.client.uicomponents.editbox.SearchSamplesBox;
import org.oslims.client.view.MixtureEditorView;
import org.oslims.domain.Mixture;

import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.MultiSelectionModel;

public class MixtureEditorViewImpl extends BaseViewImpl implements MixtureEditorView {

	final Button addMixtureButton = new Button("Add Mixture");
	final Button copyMixturesButton = new Button("Copy selected");
	final Button markMixturesRecievedButton = new Button("Mark as Prepared");
	final Button importMixturesButton = new Button("Import Mixtures");

	final EditMixtureBox editMixtureBox = new EditMixtureBox();

	final ConfirmationBox confirmationBox = new ConfirmationBox();
	final EnterStoragePlaceBox enterStoragePlaceBox = new EnterStoragePlaceBox();
	final SearchSamplesBox searchSamplesBox = new SearchSamplesBox();

	Integer defaultPageSize = 15;
	final CellTable<Mixture> mixtureTable = new CellTable<Mixture>(defaultPageSize);
	final SimplePager<Mixture> pager = new SimplePager<Mixture>(mixtureTable);
	final MultiSelectionModel<Mixture> sm = new MultiSelectionModel<Mixture>();

	public MixtureEditorViewImpl() {
		VerticalPanel vp = new VerticalPanel();

		mixtureTable.setSelectionModel(sm);

		vp.add(mixtureTable);
		vp.add(pager);

		HorizontalPanel hp = new HorizontalPanel();
		hp.add(addMixtureButton);
		hp.add(addMixtureButton);
		hp.add(copyMixturesButton);
		hp.add(markMixturesRecievedButton);
		hp.add(importMixturesButton);

		vp.add(hp);

		vp.setStyleName("editPanel");

		initWidget(vp);
	}

	@Override
	public ConfirmationBox getConfirmationBox() {
		return confirmationBox;
	}

	@Override
	public HasClickHandlers getCopyMixtureButton() {
		return copyMixturesButton;
	}

	@Override
	public EditMixtureBox getEditMixtureBox() {
		return editMixtureBox;
	}

	@Override
	public EnterStoragePlaceBox getEnterStoragePlaceBox() {
		return enterStoragePlaceBox;
	}

	@Override
	public HasClickHandlers getMarkMixtureAsPreparedButton() {
		return markMixturesRecievedButton;
	}

	@Override
	public SearchSamplesBox getSearchSamplesBox() {
		return searchSamplesBox;
	}

	@Override
	public HasClickHandlers getImportMixturesButton() {
		return importMixturesButton;
	}

	@Override
	public HasClickHandlers getAddMixtureButton() {
		return addMixtureButton;
	}

	@Override
	public Integer getDefaultPageSize() {
		return defaultPageSize;
	}

	@Override
	public SimplePager<Mixture> getPager() {
		return pager;
	}

	@Override
	public MultiSelectionModel<Mixture> getSelectionModel() {
		return sm;
	}

	@Override
	public CellTable<Mixture> getTable() {
		return mixtureTable;
	}

}
